home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_03_02 / 3n02048b < prev    next >
Text File  |  1991-12-15  |  3KB  |  83 lines

  1.  
  2. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-Begin Listing 9-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  3. /*****************************************************/
  4. /* transbtn.c                                        */
  5. /* -- Module implements a transparent control that   */
  6. /*    notifies is parent when clicked on.            */
  7. /*****************************************************/
  8.  
  9. #include <windows.h>
  10. #include "transbtn.h"
  11.  
  12. DWORD    FAR PASCAL  TransButtonWndProc(HWND, WORD,
  13.                       WORD, DWORD);
  14.  
  15. BOOL
  16. FCreateTransButtonClass(HANDLE hins, HCURSOR hcsr)
  17. /*****************************************************/
  18. /* -- Create a window class for the control.         */
  19. /* -- Call this routine when initializing the first  */
  20. /*    instance of the application.                   */
  21. /* -- Return false if the class could not be         */
  22. /*    registered.                                    */
  23. /* -- hins  : Application's instance handle.         */
  24. /* -- hcsr  : Class cursor.                          */
  25. /*****************************************************/
  26.     {
  27.     WNDCLASS    wcs;
  28.  
  29.     wcs.style = 0;
  30.     wcs.lpfnWndProc = TransButtonWndProc;
  31.     wcs.cbClsExtra = 0;
  32.     wcs.cbWndExtra = 0;
  33.     wcs.hInstance = hins;
  34.     wcs.hIcon = NULL;
  35.     wcs.hCursor = hcsr;
  36.     wcs.hbrBackground = NULL;
  37.     wcs.lpszMenuName = NULL;
  38.     wcs.lpszClassName = szTransButtonClass;
  39.     return RegisterClass(&wcs);
  40.     }
  41.  
  42. DWORD FAR PASCAL
  43. TransButtonWndProc(HWND hwnd, WORD wm, WORD wmp,
  44.   DWORD lwmp)
  45. /*****************************************************/
  46. /* -- Window procedure for transparent control.      */
  47. /* -- hwnd  : Window receiving message.              */
  48. /* -- wm    : Message number.                        */
  49. /* -- wmp   : Word sized message parameter.          */
  50. /* -- lwmp  : Long word sized message parameter.     */
  51. /*****************************************************/
  52.     {
  53.     switch (wm)
  54.         {
  55.     default:
  56.         return DefWindowProc(hwnd, wm, wmp, lwmp);
  57.  
  58.     case WM_ERASEBKGND:
  59.         break;
  60.  
  61.     case WM_PAINT:
  62.         {
  63.         PAINTSTRUCT wps;
  64.  
  65.         /* Need to call BeginPaint()/EndPaint() so */
  66.         /* that the WM_PAINT messge gets removed */
  67.         /* from the queue. */
  68.         BeginPaint(hwnd, &wps);
  69.         EndPaint(hwnd, &wps);
  70.         }
  71.         break;
  72.  
  73.     case WM_LBUTTONDOWN:
  74.         SendMessage(GetParent(hwnd), WM_COMMAND,
  75.           GetWindowWord(hwnd, GWW_ID),
  76.           MAKELONG(hwnd, BN_CLICKED));
  77.         break;
  78.         }
  79.  
  80.     return TRUE;
  81.     }
  82.  
  83.